<template>
  <div class="home">
     <BaseTable :pageList="pageList"></BaseTable>
     <PageCom
      :size="pageObj.size"
      :currentPage="currentPage"
      :total="total"
      @handleCurrentChange="handleCurrentChange"
     ></PageCom>
  </div>
</template>

<script>
import BaseTable from '@/components/baseTable';
import PageCom from '@/components/page'
import axios from 'axios';
export default {
  name: 'Home',
  data() {
    return {
      pageList: [],
      pageObj: {
        page: 0,
        size: 5
      },
      currentPage: 1,
      total: 0,

    }
  },
  components: {   
    BaseTable,
    PageCom
  },
  mounted() {
    this.getPage({}) 
  },
  methods: {
    handleCurrentChange(val) {
     this.getPage({page: val-1})
    },
    async getPage({page = this.pageObj.page, size = this.pageObj.size}) {
     const data = await axios.get('http://localhost:3000/api/user/page',{
       params: {page,size}
     })
     if (data.data.err_code === 0) {
       let list = data.data;
       this.pageList = list.data
       this.total = list.total
     }
    }
  },
}
</script>
